//
//  IsLanTabHead.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/3/3.
//  Copyright © 2016年 game. All rights reserved.
//

#import "IsLanTabHead.h"
#import "TQStarRatingView.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
@interface IsLanTabHead ()
/**
 *  标题
 */
@property (weak, nonatomic) IBOutlet UILabel *title;
/**
 *  评论的张条数
 */
@property (weak, nonatomic) IBOutlet UILabel *count;

/**
 *  电话认证
 */
@property (weak, nonatomic) IBOutlet UIButton *dianhua;
/**
 *  图片的宽度
 */
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *IMgWidth;



@property (nonatomic,strong) TQStarRatingView *starRating;

/**
 *  显示上传第一张图片Lab
 */
@property (nonatomic,strong) UILabel *shangChuan;

/**
 *  显示图片的个数
 */
@property (nonatomic,strong) UILabel *imgCount;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *LightHight;

@end

@implementation IsLanTabHead

-(void)awakeFromNib{

    self.LightHight.constant = 0.5;
    self.IMgWidth.constant = SCREEN_HEIGHT*0.17;
    
    self.title.font = font(SCREEN_WIDTH*0.045);
    self.dianhua.titleLabel.font = font(SCREEN_WIDTH*0.035);
    self.count.font = font(SCREEN_WIDTH*0.035);
    
    self.dianhua.alpha = 0;

    

    /**
     *  添加 星星评分
     */

    CGFloat hh  = SCREEN_HEIGHT*0.03;
     CGFloat  ww = (hh*(1.05))*5+(hh/1.5);
    CGFloat yy = (SCREEN_HEIGHT*0.15-hh)/2;
    CGFloat xx = SCREEN_HEIGHT*0.17+15;
    
    self.starRating = [[TQStarRatingView alloc]initWithFrame:CGRectMake(xx, yy, ww, hh)];
    [self addSubview:self.starRating];
    
    
    self.starRating.userInteractionEnabled = YES;
   
    
    /**
     *  image上添加控件
     */
    self.shangChuan = [self labCreat];
    [self.shangChuan mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.ImgShow);
    }];
    self.shangChuan.alpha = 0;
    
//    self.imgCount = [self labCreat];
//    radius(self.imgCount, 10);
//    [self.imgCount mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.bottom.equalTo(self.ImgShow).offset(-2);
//        make.width.equalTo(@20);
//        make.height.equalTo(@20);
//    }];

    self.alpha = 0;
    
}


-(void)setModel:(islanDescribDiaochangModel *)model{
    _model = model;
    
    if (_model==nil) {
        self.alpha = 0;
    }else{
        [self.ImgShow sd_setImageWithURL:[NSURL URLWithString:_model.thum]];
        self.shangChuan.text = @"上传第一张相片";
        self.imgCount.text = @"3";
        
        self.title.text = _model.name;
        [self.starRating StarForegroundViewWithScore:_model.score];
        
        self.count.text = [NSString stringWithFormat:@"%ld 条评论",(unsigned long)_model.comments.count];
        
        if (_model.identify.integerValue==2) {
            self.dianhua.alpha = 1;
        }else{
            self.dianhua.alpha = 0;
        }
        
        self.alpha = 1;
    }
        
    

    
}

-(UILabel *)labCreat{
    UILabel *lab = [UILabel new];
    lab.backgroundColor = TouMingBlack2;
    lab.textColor = [UIColor whiteColor];
    lab.font = font(SCREEN_WIDTH*0.035);
    lab.textAlignment = NSTextAlignmentCenter;
    [self.ImgShow addSubview:lab];
    
    return lab;
}
@end
